<?php

class Application_Registry implements Application_Interface_Registry, Application_Interface_Singleton {
    
    /**
     * @var Application_Registry
     */
    private static $_instance;
    
    protected $_values = array();
    
    /**
     * @return Application_Registry
     */
    public static function getInstance() {
        if(self::$_instance === null) {
            self::$_instance = new self;
        }
        return self::$_instance;
    }
    
    public function get($key) {
        if (isset($this->_values[$key])) {
            return $this->_values[$key];
        }
    }
    
    public function set($key, $value) {
       $this->_values[$key] = $value;
       if ($value === null) {
           unset($this->_values[$key]);
       }
    }
    
    public function __get($key) {
        return $this->get($key);
    }
    
    public function __set($key, $value) {
        $this->set($key, $value);
    }
    
    public function __isset($key) {
        return isset($this->_values[$key]);
    }
    
    public function __unset($key) {
        unset($this->_values[$key]);
    }
    
    public function getValues() {
        return $this->_values;
    }
    
}

?>